package com.example.tests;

import static org.hamcrest.MatcherAssert.*;
import static org.hamcrest.Matchers.*;


import java.io.IOException;
import java.util.Random;

import org.testng.annotations.Test;

import com.example.fw.Folders;

public class TestFolderRemoval extends TestBase {

	@Test
	public void testFolderDeletion() throws IOException {
		// save old state
		Folders oldFolders = app.getFolderHelper().getFolders();
		
		// actions
		if (oldFolders.size() > 0) {
			app.getFolderHelper().deleteFolder(0); // actions
			Folders newFolders = app.getFolderHelper().getFolders(); // save new state
			assertThat(newFolders, equalTo(oldFolders.without(0))); // compare states
		} else {
			System.out.println("List of folders is empty");
			return;
		}
		
		
	}

	//@Test
	public void testFolderDeletionByIndex() throws IOException {
		Folders oldFolders = app.getFolderHelper().getFolders();

		

		if (oldFolders.size() > 0 ) {
			Random rnd = new Random();
			int index = rnd.nextInt(oldFolders.size());
			app.getFolderHelper().deleteFolder(index);
			Folders newFolders = app.getFolderHelper().getFolders();
			assertThat(newFolders, equalTo(oldFolders.without(index)));
		} else {
			System.out.println("List of folders is empty");
			return;
		}

	}
		 
}
